package study.java.thread09;

/**
* @Name: MyThreadDemo
* @Description: 匿名内部类方式使用多线程测试类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-10 上午9:56:21 
* @Version: V1.0
 */
public class MyThreadDemo {
	
	public static void main(String[] args) {
		//继承Thread类
		new Thread() {
			public void run() {
				for (int i = 0; i < 10; i++) {
					System.out.println(Thread.currentThread().getName() + ":" + i);
				}
			};
		}.start() ;
		//实现Runnable接口
		new Thread(new Runnable() {
			@Override
			public void run() {
				for (int i = 0; i < 100; i++) {
					System.out.println(Thread.currentThread().getName() + ":" + i);
				}
			}
		}){
		}.start() ;
		//即继承Thread类又实现Runnable接口时：只执行继承Thread类的匿名内部类中的run()方法，不执行实现Runnable接口的匿名内部类中的run()方法
		new Thread(new Runnable() {
			@Override
			public void run() {
				for (int i = 0; i < 10; i++) {
					System.out.println("hello:" + i);
				}
			}
		}) {
			@Override
			public void run() {
				for (int i = 0; i < 10; i++) {
					System.out.println("world:" + i);
				}
			}
		}.start() ;
	}

}
